package cn.iocoder.yudao.module.shop.dal.mysql.monthmember;

import java.time.LocalDateTime;
import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.shop.dal.dataobject.monthmember.ShopMonthMemberDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.shop.controller.admin.monthmember.vo.*;

/**
 * 顾客每月到店统计 Mapper
 *
 * @author 曹建伟
 */
@Mapper
public interface ShopMonthMemberMapper extends BaseMapperX<ShopMonthMemberDO> {

    default PageResult<ShopMonthMemberDO> selectPage(ShopMonthMemberPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ShopMonthMemberDO>()
                .eqIfPresent(ShopMonthMemberDO::getDateId, reqVO.getDateId())
                .betweenIfPresent(ShopMonthMemberDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ShopMonthMemberDO::getId));
    }

    default List<ShopMonthMemberDO> selectList(ShopMonthMemberExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ShopMonthMemberDO>()
                .eqIfPresent(ShopMonthMemberDO::getDateId, reqVO.getDateId())
                .betweenIfPresent(ShopMonthMemberDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ShopMonthMemberDO::getId));
    }

    default List<ShopMonthMemberDO> selectListByTime(LocalDateTime startTime, LocalDateTime endTime, Long tenantId){
        return selectList(new LambdaQueryWrapper<ShopMonthMemberDO>()
                .eq(ShopMonthMemberDO::getTenantId, tenantId)
                .between(ShopMonthMemberDO::getCreateTime, startTime, endTime));
    }

}
